home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj1086.arc / READDIR2.ASM < prev    next >
Assembly Source File  |  1986-08-14  |  2KB  |  88 lines

  1. ;LISTING 2:  READDIR2.ASM
  2. ;
  3. ; This program reads the directory from the diskette in drive A.
  4. ; The input buffer area is outside the program's segment and is
  5. ; obtained from the DOS memory pool by calling DOS Function 48H,
  6. ; after calling DOS Function 4AH to "shrink" the memory allocated
  7. ; to the program.  For the sake of simplicity no console input or
  8. ; output functions are performed by this program.
  9. ;
  10. CODESEG    SEGMENT    PARA   PUBLIC   'CODE'
  11. ;
  12. ;
  13.     ASSUME    CS:CODESEG,DS:CODESEG,ES:CODESEG,SS:CODESEG
  14. ;
  15.     ORG    0100H
  16. ;
  17. BEGIN:    JMP    READ_DIRECTORY
  18. ;
  19. ; ************************  Main Procedure  **************************
  20. ;
  21. READ_DIRECTORY:
  22. ;
  23. ; "Shrink" the program memory allocation by calling DOS Function 4AH
  24. ;
  25.     MOV    BX,4096        ; 64K for the program
  26.     MOV    AH,4AH        ; DOS function
  27.     INT    21H        ; Function request
  28.     JC    ERROR_EXIT_1    ; Quit if there was an error
  29. ;
  30. ; Request DOS to allocate a block of memory for the disk input area
  31. ;
  32.     MOV    BX,224        ; Room for 7 sectors
  33.     MOV    AH,48H        ; DOS function
  34.     INT    21H        ; Function Request
  35.     JC    ERROR_EXIT_1    ; Quit if there was an error
  36.     MOV    ES,AX        ; Move segment from AX to ES
  37. ;
  38. ; Set breakpoint for DEBUG so that the registers can be examined
  39. ;
  40.     INT    03H        ; DEBUG breakpoint
  41. ;
  42. ; Setup DS for the Absolute Disk Read
  43. ;
  44.     PUSH    DS        ; Save DS
  45.     MOV    AX,ES        ; MOVE the contents of ES to DS
  46.     MOV    DS,AX        ;    via AX
  47. ;
  48. ; Setup the registers for the Absolute Disk Read
  49. ;
  50.     MOV    AL,00H        ; Drive A
  51.     XOR    BX,BX        ; Point to the beginning
  52.                 ;    of the memory area
  53.     MOV    CX,0007H    ; 7 sectors to be read
  54.     MOV    DX,0005H    ; Start at sector 5
  55.     INT    25H        ; Absolute Disk Read Interrupt
  56.     JC    ERROR_EXIT_2    ; Quit if there was an error
  57.     POPF            ; Restore the user flags
  58.     POP    DS        ; Restore DS
  59. ;
  60. ; Free the allocated memory block prior to returning to DOS
  61. ;
  62.     MOV    AH,49H        ; DOS function
  63.     INT    21H        ; Function Request
  64.     RET            ; Return to DOS
  65. ;
  66. ; Error return without popping the stack
  67. ;
  68. ERROR_EXIT_1:
  69.     RET            ;Return to DOS
  70. ;
  71. ; Error return with popping the stack
  72. ;
  73. ERROR_EXIT_2:
  74.     POP    DI        ; Throw away the user flags
  75.     POP    DS        ; Restore DS
  76. ;
  77. ; Free the allocated memory block prior to returning to DOS
  78. ;
  79.     MOV    AH,49H        ; DOS function
  80.     INT    21H        ; Function Request
  81.     RET            ; Return to DOS
  82. ;
  83. CODESEG    ENDS
  84. ;
  85. ; ********************************************************************
  86. ;
  87.     END    BEGIN
  88.